<html>
<head><meta charset="utf-8"><title>Declarative macro repetition counts · t-lang · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/index.html">t-lang</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html">Declarative macro repetition counts</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201744788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201744788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201744788">(Jun 23 2020 at 15:53)</a>:</h4>
<p>Hi.  I have a small idea for an improvement to declarative macros.  @dtolnay said I should post here to see if there is any merit in proceeding further.<br>
The idea is to add a way to find out the number of repetitions of a metavar in declarative macros, something I've needed to do a few times in the past.  I've started writing a pre-RFC at <a href="https://github.com/markbt/rfcs/blob/macro_repetition_count/text/0000-macro-repetition-count.md">https://github.com/markbt/rfcs/blob/macro_repetition_count/text/0000-macro-repetition-count.md</a> explaining the rationale and what it would look like.<br>
Does this seem worth pursuing? I think it's fairly low effort to add (I already have a working prototype) but would be quite useful.</p>



<a name="201745691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201745691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201745691">(Jun 23 2020 at 16:00)</a>:</h4>
<p>I like this idea.</p>



<a name="201745795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201745795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201745795">(Jun 23 2020 at 16:01)</a>:</h4>
<p>Reasonable, justified, self-contained...</p>



<a name="201745836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201745836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201745836">(Jun 23 2020 at 16:01)</a>:</h4>
<p>Already prototyped. :)</p>



<a name="201745953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201745953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201745953">(Jun 23 2020 at 16:02)</a>:</h4>
<p>I also like the syntax for future expansion, and can think of several ways we could use that later.</p>



<a name="201750960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201750960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201750960">(Jun 23 2020 at 16:43)</a>:</h4>
<p>Cool!  Are there any changes you'd like me to make to the draft before I turn it into a PR?  (I assume the next step is to make a PR in rfcs, but I'm new to this).</p>



<a name="201751293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201751293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201751293">(Jun 23 2020 at 16:45)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> Do you think this change should go straight to RFC (given the already-written RFC) or use the lang MCP?</p>



<a name="201760634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201760634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201760634">(Jun 23 2020 at 18:04)</a>:</h4>
<p><span class="user-mention" data-user-id="312456">@Mark Thomas</span>  Not sure if it's helpful, but you can find my original implementation of <code>?</code> in this PR: <a href="https://github.com/rust-lang/rust/pull/47752">https://github.com/rust-lang/rust/pull/47752</a> (though, the code has changed a bit since then)...</p>



<a name="201760682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201760682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201760682">(Jun 23 2020 at 18:04)</a>:</h4>
<p>Ah, but I see you already have a prototype... Awesome!</p>



<a name="201776593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201776593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201776593">(Jun 23 2020 at 20:15)</a>:</h4>
<p>This should (imo) be a lang MCP</p>



<a name="201776599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201776599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201776599">(Jun 23 2020 at 20:15)</a>:</h4>
<p>but we can move it quickly enough :)</p>



<a name="201776609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201776609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201776609">(Jun 23 2020 at 20:15)</a>:</h4>
<p>let's try to prototype new process</p>



<a name="201822913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201822913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201822913">(Jun 24 2020 at 08:31)</a>:</h4>
<p>Is there a guide for lang MCPs?  I could only find the compiler-team's MCP process on forge (<a href="https://forge.rust-lang.org/compiler/mcp.html">https://forge.rust-lang.org/compiler/mcp.html</a>).</p>



<a name="201822986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201822986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201822986">(Jun 24 2020 at 08:32)</a>:</h4>
<p>There's a template in the lang-team repository, and some example issues.</p>



<a name="201834594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/213817-t-lang/topic/Declarative%20macro%20repetition%20counts/near/201834594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mark Juggurnauth-Thomas <a href="https://rust-lang.github.io/zulip_archive/stream/213817-t-lang/topic/Declarative.20macro.20repetition.20counts.html#201834594">(Jun 24 2020 at 11:04)</a>:</h4>
<p>I've opened <a href="https://github.com/rust-lang/lang-team/issues/28">https://github.com/rust-lang/lang-team/issues/28</a> using the template and copying text from the draft.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>